﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using ElectronicCommerce.Framework.ExceptionManagement;
using ElectronicCommerce.Framework.Web.ResourceManagement;
using ElectronicCommerce.Framework.Web.StateManagement;

namespace ElectronicCommerce.Framework.Web.UI
{
    public class UserControlBase : UserControl
    {
        protected PageBase ContentPage
        {
            get { return Page as PageBase; }
        }

        protected PageHead PageHead
        {
            get { return ContentPage.PageHead; }
        }

        public ResourceBuilder Resource
        {
            get { return ContentPage.Resource; }
        }

        public UrlBuilder Url
        {
            get { return ContentPage.Url; }
        }


        public IStateProvider State
        {
            get { return ContentPage.State; }
        }

        public ExManager ExceptionManager
        {
            get
            {
                return ContentPage.ExceptionManager;
            }
        }

        public string BuildText(string stringResource)
        {
            return ContentPage.BuildText(stringResource);
        }

        /// <summary>
        /// Get a html block string by the alias
        /// </summary>
        /// <param name="alias"></param>
        /// <returns>The block html or empty string if there is no such alias in config files</returns>
        public string BuildHtml(string alias)
        {
            return ContentPage.BuildHtml(alias);
        }

        /// <summary>
        /// Build image 
        /// </summary>
        /// <param name="mediaName"></param>
        /// <returns></returns>
        public string BuildMedia(string mediaName)
        {
            return Resource.BuildMedia(mediaName);
        }

        /// <summary>
        /// Build error message
        /// </summary>
        /// <param name="errorCode"></param>
        /// <returns></returns>
        public virtual string BuildErrorMessage(string errorCode)
        {
            return ContentPage.BuildErrorMessage(errorCode);
        }
        /// <summary>
        /// Build Error Title
        /// </summary>
        /// <param name="errorCode"></param>
        /// <returns></returns>
        public virtual string BuildErrorTitle(string errorCode)
        {
            return ContentPage.BuildErrorTitle(errorCode);
        }
    }
}
